

package cn.shengchao.examstar.distributor.gateway.controller;

import cn.shengchao.examstar.distributor.gateway.service.DistributorService;
import cn.shengchao.examstar.distributor.gateway.service.message.DistributorIndexInfo;
import cn.shengchao.examstar.distributor.gateway.service.message.Rankings;
import cn.shengchao.util.helper.LoginHelper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Slf4j
@CrossOrigin("${project.cross-origin}")
@RequestMapping("/api/${project.version}/distributor/index")
public class DistributorIndexController {
    @Autowired
    private DistributorService distributorService;

    /**
     * 首页数据
     */
    @GetMapping()
    public DistributorIndexInfo getDistributorIndexInfo() {
        return distributorService.getDistributorIndexInfo(LoginHelper.getUserId());
    }

    /**
     * 首页排行榜
     */
    @GetMapping("ranking")
    public List<Rankings> getDistributorRanking(@RequestParam("rankType") Long rankType) {
        return distributorService.getDistributorRanking(LoginHelper.getUserId(), rankType);
    }

}
